import matplotlib
matplotlib.rcParams['backend'] = 'TkAgg'   # 或者 'Qt5Agg' 等其他后端
import matplotlib.pyplot as plt
import seaborn as sns

#  使用Seaborn内置的数据集
tips = sns.load_dataset('tips')

#  创建分类散点图和回归线
sns.lmplot(x='total_bill', y='tip', data=tips, hue='sex')

#  添加标题和标签
plt.title('Total  Bill  vs  Tip  with  Regression  Line  (Separated  by  Gender)')
plt.xlabel('Total  Bill  ($)')
plt.ylabel('Tip  ($)')

#  显示图形
plt.show()
